home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / Language (lang) / GCC / GCC 1.37.1r7(Min) / Scripts / gC next >
Encoding:
Text File  |  1990-12-12  |  6.8 KB  |  272 lines  |  [TEXT/MPS ]

  1. # This script runs the preprocessor, compiler, and assembler, with appropriate
  2. # options.
  3. #
  4. # Copyright © 1989, 1990 Apple Computer, Inc.
  5.  
  6. set echo 0  # Build cmds turn echo on, sigh, so we have to turn it off again.
  7. set exit 0  # So we can do cleanup ourselves.
  8.  
  9. # Default is to run everything.
  10. set run-cpp 1
  11. set run-cc1 1
  12. set run-asm 1
  13.  
  14. set output-filename ""
  15. set cpp-options "-D__GNUC__"  # This is not built into the preprocessor.
  16. set cc1-options ""
  17. set asm-options "-w"
  18. set tmp ":"
  19. set toolplace ""
  20.  
  21. set echo-cmds 0
  22. set quiet-flag 1
  23. set optimize 1   # this is "-opt on"
  24.  
  25. set dash-mc68020 0
  26. set dash-m 0
  27.  
  28. # Scan all the command line arguments, distributing them to the appropriate
  29. # programs' command lines, translating when necessary.
  30. loop
  31.     break if {#} == 0
  32.     if "{1}" =~ /-a?*/
  33.         if "{1}" =~ /-ansi/
  34.             set cc1-options "{cc1-options} -ansi"
  35.         else if "{1}" =~ /-asm/
  36.             set run-asm 0
  37.         end
  38.     else if "{1}" =~ /-b?*/
  39.         if "{1}" =~ /-b/
  40.             set cc1-options "{cc1-options} -mb"
  41.         else if "{1}" =~ /-b2/
  42.             echo Warning: -b2 ignored, substituting -b
  43.             set cc1-options "{cc1-options} -mb"
  44.         else if "{1}" =~ /-b3/
  45.             echo Warning: -b3 ignored, substituting -b
  46.             set cc1-options "{cc1-options} -mb"
  47.         else if "{1}" =~ /-bigseg/
  48.             echo Warning: Ignoring -bigseg
  49.         end
  50.     else if "{1}" =~ /-c/
  51.         set run-cc1 0  # also need to delete asm file
  52.     else if "{1}" =~ /-d?*/
  53.         if "{1}" =~ /-d/
  54.             shift 1
  55.             set cpp-options "{cpp-options} -D{1}"
  56.         else if "{1}" =~ /-d?+/
  57.             set cc1-options "{cc1-options} {1}"
  58.         end
  59.     else if "{1}" =~ /-e?*/
  60.         if "{1}" =~ /-e/
  61.             set cpp-options "{cpp-options} -C"
  62.             set run-cc1 0
  63.         else if "{1}" =~ /-e2/
  64.             set run-cc1 0
  65.         else if "{1}" =~ /-elems881/
  66.             # -melems881 will also turn on -mc68881
  67.             set cc1-options "{cc1-options} -melems881"
  68.         end
  69.     else if "{1}" =~ /-f?*/
  70.         if "{1}" =~ /-fx/
  71.             shift 1
  72.             if "{1}" =~ /30/
  73.                 set cc1-options "{cc1-options} -mfx30"
  74.             else
  75.                 echo Warning: -fx {1} being ignored
  76.             end
  77.         else if "{1}" =~ /-f?+/
  78.             set cc1-options "{cc1-options} {1}"
  79.         end
  80.     else if "{1}" =~ /-i/
  81.         shift 1
  82.         set cpp-options "{cpp-options} '-I{1}'"
  83.     else if "{1}" =~ /-k/
  84.         shift 1
  85.         echo Warning: Ignoring -k
  86.     else if "{1}" =~ /-m?*/
  87.         if "{1}" =~ /-m/
  88.             set dash-m 1
  89.         else if "{1}" =~ /-makedep/
  90.             set cpp-options "{cpp-options} -M"
  91.             set run-cc1 0
  92.         else if "{1}" =~ /-mbg/
  93.             shift 1
  94.             if "{1}" =~ /off/
  95.                 set cc1-options "{cc1-options} -mbgoff -fomit-frame-pointer"
  96.             else if "{1}" =~ /full/
  97.                 # default case
  98.             else
  99.                 echo Warning: only -mbg off and -mbg full are understood
  100.             end
  101.         else if "{1}" =~ /-mc68020/
  102.             set dash-mc68020 1
  103.         else if "{1}" =~ /-mc68881/
  104.             set cpp-options "{cpp-options} -Dmc68881"
  105.             set cc1-options "{cc1-options} -mc68881"
  106.         else if "{1}" =~ /-mnoseg/
  107.             set cc1-options "{cc1-options} -mnoseg"
  108.         end
  109.     else if "{1}" =~ /-notonce/
  110.         echo Warning: -notonce being ignored
  111.     else if "{1}" =~ /-n/
  112.         echo Warning: -n being ignored
  113.     else if "{1}" =~ /-o?*/
  114.         if "{1}" =~ /-opt/
  115.             shift 1
  116.             if "{1}" =~ /off/
  117.                 set optimize 0
  118.             else if "{1}" =~ /on?*/
  119.                 set optimize 1
  120.             else if "{1}" =~ /full?*/
  121.                 set optimize 2
  122.             end
  123.         else if "{1}" =~ /-o/
  124.             shift 1
  125.             set output-filename "{1}"
  126.         end
  127.     else if "{1}" =~ /-p?*/
  128.         if "{1}" =~ /-p/
  129.             set cpp-options "{cpp-options} -v"
  130.             set cc1-options "{cc1-options} -version"
  131.             set quiet-flag 0
  132.             set asm-options "{asm-options} -p"
  133.             set echo-cmds 1
  134.         else if "{1}" =~ /-pedantic/
  135.             set cpp-options "{cpp-options} -pedantic"
  136.             set cc1-options "{cc1-options} -pedantic"
  137.         end
  138.     else if "{1}" =~ /-r/
  139.         set cc1-options "{cc1-options} -Wimplicit"
  140.     else if "{1}" =~ /-s?*/
  141.         if "{1}" =~ /-s/
  142.             shift 1
  143.             set cc1-options "{cc1-options} -s '{1}'"
  144.         else if "{1}" =~ /-sym/
  145.             shift 1
  146.             echo Warning: Symbolic info will be whatever the assembler produces
  147.             set asm-options "{asm-options} -sym {1}"
  148.         end
  149.     else if "{1}" =~ /-t?*/
  150.         if "{1}" =~ /-trace/
  151.             shift 1
  152.             set cc1-options "{cc1-options} -trace '{1}'"
  153.         else if "{1}" =~ /-t/
  154.             set quiet-flag 0
  155.             set asm-options "{asm-options} -t"
  156.         else if "{1}" =~ /-tools/
  157.             shift 1
  158.             set toolplace "{1}" 
  159.         else if "{1}" =~ /-traditional/
  160.             set cc1-options "{cc1-options} -traditional"
  161.             set cpp-options "{cpp-options} -traditional"
  162.         end
  163.     else if "{1}" =~ /-u/
  164.         shift 1
  165.         set cpp-options "{cpp-options} -U{1}"
  166.     else if "{1}" =~ /-w?*/
  167.         if "{1}" =~ /-warnings/
  168.             shift 1
  169.             if "{1}" =~ /off/
  170.                 set cc1-options "{cc1-options} -w"
  171.             else if "{1}" =~ /on/
  172.                 set cc1-options "{cc1-options} -Wall"
  173.             else if "{1}" =~ /full/
  174.                 set cc1-options "{cc1-options} -Wall"
  175.             end
  176.         else if "{1}" =~ /-w/
  177.             set cc1-options "{cc1-options} -w"
  178.         else if "{1}" =~ /-w2/
  179.             set cc1-options "{cc1-options} -Wall"
  180.         else if "{1}" =~ /-w?+/
  181.             set cc1-options "{cc1-options} {1}"
  182.         end
  183.     else if "{1}" =~ /-y/
  184.         shift 1
  185.         set tmp "{1}"
  186.     else if "{1}" =~ /-?+/
  187.         echo Unknown option {1}
  188.         exit 2
  189.     else
  190.         set input-filename "{1}"
  191.     end
  192.     shift 1
  193. end
  194.  
  195. if {dash-m}
  196.     set cc1-options "{cc1-options} -mm"
  197.     if (! {dash-mc68020})
  198.         echo Warning: -m implies -mc68020
  199.     end
  200. end
  201.  
  202. if {dash-mc68020} || {dash-m}
  203.     set cpp-options "{cpp-options} -Dmc68020"
  204.     set cc1-options "{cc1-options} -mc68020"
  205. end
  206.  
  207. # Fix up details of parameters to the tools
  208. if "{input-filename}" == ""
  209.     echo No input filename supplied
  210.     exit 2
  211. end
  212. if "{input-filename}" =~ /:*([¬:]+:*)*([¬:]+)®1/
  213.     set tmp-filename "{tmp}{®1}"
  214. else
  215.     set tmp-filename "{tmp}{input-filename}"
  216. end
  217. if {run-cc1} == 1
  218.     set cpp-filename "{tmp-filename}".cpp
  219. else
  220.     set cpp-filename ""
  221. end
  222. set asm-filename "{tmp-filename}".a
  223. if "{output-filename}" == ""
  224.     set output-filename "{input-filename}".o
  225. end
  226.  
  227. if {quiet-flag} == 1
  228.   set cc1-options "{cc1-options} -quiet"
  229. end
  230. if {optimize} >= 1  # can't distinguish "on" and "full" yet
  231.   set cc1-options "{cc1-options} -O"
  232. end
  233.  
  234. # Run all the tools in order 
  235. if {run-cpp} == 1
  236.     if {echo-cmds} == 1
  237.         quote "{toolplace}"cpp {cpp-options} "{input-filename}" "{cpp-filename}" >> Dev:StdErr
  238.     end
  239.     "{toolplace}"cpp         {cpp-options} "{input-filename}" "{cpp-filename}"
  240.     if {status} == 0
  241.         if {run-cc1} == 1
  242.             if {echo-cmds} == 1
  243.                 quote "{toolplace}"cc1 {cc1-options} "{cpp-filename}" -o "{asm-filename}" -dumpbase "{tmp-filename}" >> Dev:StdErr
  244.             end
  245.             "{toolplace}"cc1         {cc1-options} "{cpp-filename}" -o "{asm-filename}" -dumpbase "{tmp-filename}"
  246.             if {status} == 0
  247.                 delete -i -y "{cpp-filename}"
  248.                 if {run-asm} == 1
  249.                     if {echo-cmds} == 1
  250.                         quote asm {asm-options} "{asm-filename}" -o "{output-filename}" >> Dev:StdErr
  251.                     end
  252.                     asm         {asm-options} "{asm-filename}" -o "{output-filename}"
  253.                     if {status} == 0
  254.                         delete -i -y "{asm-filename}"
  255.                     else
  256. # since the assembler should never get errors, leave the asm file around
  257. #            delete -i -y "{asm-filename}"
  258.                         exit 2
  259.                     end
  260.                 end
  261.             else
  262.                 delete -i -y "{cpp-filename}"
  263.                 delete -i -y "{asm-filename}"
  264.                 exit 2
  265.             end
  266.         end
  267.     else
  268.         delete -i -y "{cpp-filename}"
  269.         exit 2
  270.     end
  271. end
  272.